package com.example.common.entity;

import jdk.net.SocketFlow;

import java.io.Serializable;

/**
 * @author humeihua
 */
public class ResultDO<T>  implements Serializable {
    private T model;
    private Boolean result;
    private String resultMsg;
    private Integer currentPage;
    private Integer totalPage;
    private Integer size;
    private Integer errorCode;
    private int totalCount;

    public ResultDO() {
    }

    public ResultDO(boolean result) {
        this.result = result;
    }

    public ResultDO(T t) {
        this.model = t;
        this.result = true;
        this.errorCode=StatusCode.OK;
    }

    public ResultDO(boolean result, String resultMsg) {
        this.result = result;
        this.resultMsg = resultMsg;
        this.errorCode=StatusCode.OK;
    }

    public  static <T> ResultDO ok(T t){
        return  new ResultDO(t);
    }
    public  static  ResultDO error(Integer statusCode,String resultMsg){
        ResultDO resultDO = new ResultDO();
        resultDO.setErrorCode(statusCode);
        resultDO.setResultMsg(resultMsg);
        resultDO.setResult(false);
        return  resultDO;
    }

    public T getModel() {
        return this.model;
    }

    public void setModel(T model) {
        this.model = model;
    }

    public Boolean getResult() {
        return this.result;
    }

    public void setResult(Boolean result) {
        this.result = result;
    }

    public String getResultMsg() {
        return this.resultMsg;
    }

    public void setResultMsg(String resultMsg) {
        this.resultMsg = resultMsg;
    }

    public Integer getCurrentPage() {
        return this.currentPage;
    }

    public void setCurrentPage(Integer currentPage) {
        this.currentPage = currentPage;
    }

    public Integer getTotalPage() {
        return this.totalPage;
    }

    public void setTotalPage(Integer totalPage) {
        this.totalPage = totalPage;
    }

    public Integer getSize() {
        return this.size;
    }

    public void setSize(Integer size) {
        this.size = size;
    }

    public Integer getErrorCode() {
        return this.errorCode;
    }

    public void setErrorCode(Integer errorCode) {
        this.errorCode = errorCode;
    }

    public int getTotalCount() {
        return this.totalCount;
    }

    public void setTotalCount(int totalCount) {
        this.totalCount = totalCount;
    }

    @Override
    public String toString() {
        return "ResultDO{model=" + this.model + ", result=" + this.result + ", resultMsg='" + this.resultMsg + '\'' + ", currentPage=" + this.currentPage + ", totalPage=" + this.totalPage + ", size=" + this.size + ", errorCode=" + this.errorCode + '}';
    }
}
